#ifndef TECLADO_H_
#define TECLADO_H_

#include "pantalla.h"

#define LEFT_MAKE_SHIFT 0x2A
#define LEFT_BREAK_SHIFT 0xAA
#define RIGHT_MAKE_SHIFT 0x36
#define RIGHT_BREAK_SHIFT 0xB6
#define MAKE_BLOCK_MAYUS 0x3A	// constantes para leer el codigo que viene
#define NADA 0					// del teclado

#define BUFFER_TECLADO (COLUMNAS*FILAS)

FD *teclado;
int shift;
char bufferTeclado[BUFFER_TECLADO];

static char ScanCodes[][2] = {
    {NADA,NADA},{NADA,NADA},{'!','1'},{'@','2'},{'#','3'},{'$','4'},
	{'%','5'},{'^','6'},{'&','7'},{'*','8'},{'(','9'},{')','0'},{'_','-'},
	{'+','='},{'\b','\b'},{'\t','\t'},{'Q','q'},{'W','w'},{'E','e'},{'R','r'},
	{'T','t'},{'Y','y'},{'U','u'},{'I','i'},{'O','o'},{'P','p'},{'{','['},
	{'}',']'},{'\n','\n'},{NADA,NADA},{'A','a'},{'S','s'},{'D','d'},{'F','f'},
	{'G','g'},{'H','h'},{'J','j'},{'K','k'},{'L','l'},{':',';'},{'"','\''},
	{'|','\\'},{NADA,NADA},{'>','<'},{'Z','z'},{'X','x'},{'C','c'},{'V','v'},
	{'B','b'},{'N','n'},{'M','m'},{'<',','},{'>','.'},{'?','/'},{NADA,NADA},
	{'*','*'},{NADA,NADA},{' ',' '},{NADA,NADA},
	{NADA,NADA},/*059 F1*/{NADA,NADA},/*060 F2*/{NADA,NADA},/*061 F3*/
	{NADA,NADA},/*062 F4*/{NADA,NADA},/*063 F5*/{NADA,NADA},/*064 F6*/
	{NADA,NADA},/*065 F7*/{NADA,NADA},/*066 F8*/{NADA,NADA},/*067 F9*/
	{NADA,NADA},/*068 F10*/{NADA,NADA},/*069 NUMLCK*/{NADA,NADA},/*070 SCRLCK*/
    {'7','7'},{'8','8'},{'9','9'},{'-','-'},{'4','4'},{'5','5'},{'6','6'},
	{'+','+'},{'1','1'},{'2','2'},{'3','3'},{'0','0'},{'.','.'},
	{NADA,NADA},/*084 SYS REQ (AT)*/{'+','*'},{'+','*'},{NADA,NADA},/*087 F11*/
    {NADA,NADA},/*088 F12*/{'+','*'},{'+','*'}
};

void inicializarTeclado();
void restartTeclado();
void agregarABuffer(char ascii);
void procTeclado(unsigned int code);
void procAscii(char ascii);
void procesaComando(char *str);

#endif /* TECLADO_H_ */
